package net.wanho.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
 * Author：汤小洋
 * Date：2023-06-29 14:10
 * Description：<描述>
 */
@WebServlet("/hello")
public class HelloServlet  extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("HelloServlet.service..............");

        req.setAttribute("name","汤小洋");

        List<String> names = Arrays.asList("aa","bb","cc");
        req.getSession().setAttribute("names",names);

        Properties properties = new Properties();
        properties.load(HelloServlet.class.getClassLoader().getResourceAsStream("datasource.properties"));
        System.out.println(properties);


        req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(req,resp);

    }
}
